package com.example.tys.daggermvp.bean;

import android.provider.MediaStore;
import android.support.annotation.Nullable;

import com.example.tys.daggermvp.utils.DisplayUtil;
import com.example.tys.daggermvp.view.recyclerviewCompant.sticky.StickyBaseData;

/**
 * 本地目录的图片和视频文件
 *
 * @author tys
 * @date 2018/4/29
 */

public class ImageBean extends StickyBaseData {
    /**
     * 数据库中的id
     */
    private String id;
    /**
     * 全路径
     */
    private String filePath;
    /**
     * 文件名(隐藏目录下的文件名为null)
     */
    @Nullable
    private String fileName;
    /**
     * 文件最后修改日期
     */
    private long modifiedDate;
    /**
     * 文件类(image/*, video/*)
     */
    private String mimeType;
    /**
     * 文件大小(bytes)
     */
    private long size;
    /**
     * 视频/图片的宽(像素)，格式不正确时其大小为0。比如强制重命名
     */
    private int width;
    /**
     * 视频/图片的高(像素)，格式不正确时其大小为0。比如强制重命名
     */
    private int height;

    public ImageBean(String id, String filePath, @Nullable String fileName, long modifiedDate, String mimeType, long size, int width, int height) {
        this.id = id;
        this.filePath = filePath;
        this.fileName = fileName;
        this.modifiedDate = modifiedDate;
        this.mimeType = mimeType;
        this.size = size;
        this.width = width;
        this.height = height;
    }

    public ImageBean() {
    }

    public static final String[] PROJECTION = {
            //The unique ID for a row   0
            MediaStore.Images.Media._ID,
            //Path to the file on disk  1
            MediaStore.Images.Media.DATA,
            //The display name of the file  2
            MediaStore.Images.Media.DISPLAY_NAME,
            //The time the file was last modified   3
            MediaStore.Images.Media.DATE_MODIFIED,
            //The MIME type of the file     4
            MediaStore.Images.Media.MIME_TYPE,
            //The width of the image/video in pixels    5
            MediaStore.Images.Media.WIDTH,
            //The height of the image/video in pixels   6
            MediaStore.Images.Media.HEIGHT,
            //The size of the file in bytes    7
            MediaStore.Images.Media.SIZE,
    };

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    @Nullable
    public String getFileName() {
        return fileName;
    }

    public void setFileName(@Nullable String fileName) {
        this.fileName = fileName;
    }

    public long getModifiedDate() {
        return modifiedDate;
    }

    public void setModifiedDate(long modifiedDate) {
        this.modifiedDate = modifiedDate;
    }

    public String getMimeType() {
        return mimeType;
    }

    public void setMimeType(String mimeType) {
        this.mimeType = mimeType;
    }

    public long getSize() {
        return size;
    }

    public void setSize(long size) {
        this.size = size;
    }

    @Nullable
    public int getWidth() {
        return width;
    }

    public void setWidth(@Nullable int width) {
        this.width = width;
    }

    @Nullable
    public int getHeight() {
        return height;
    }

    public void setHeight(@Nullable int height) {
        this.height = height;
    }

    @Override
    public String toString() {
        return "ImageBean{" +
                "id='" + id + '\'' +
                ", filePath='" + filePath + '\'' +
                ", fileName='" + fileName + '\'' +
                ", modifiedDate=" + modifiedDate +
                ", mimeType='" + mimeType + '\'' +
                ", size=" + size +
                ", width=" + width +
                ", height=" + height +
                '}';
    }

    @Override
    protected String stickTitle() {
        return DisplayUtil.formatDate("yyyy/MM/dd", modifiedDate * 1000);
    }
}
